﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace GiveGraphModel
{
    public class Organization : Member
    {

        public string Name { get; set; }
        public string FacebookToken { get; set; }

        public virtual ICollection<User> Followers { get; set; }
        public virtual ICollection<OrganizationLocation> Locations { get; set; }
        public virtual ICollection<ServiceRequest> Requests { get; set; }
        public virtual ICollection<OrganizationCategory> Categories { get; set; }
        public virtual ICollection<Event> HostedEvents { get; set; }
    }

    public sealed class OrganizationConfiguration : EntityTypeConfiguration<Organization>
    {
        public OrganizationConfiguration()
        {
            Property(o => o.Name).IsRequired();
            Property(o => o.FacebookToken).IsRequired();
            HasMany(o => o.Categories).WithMany();
            
            HasMany(o=>o.Locations)
                .WithRequired().WillCascadeOnDelete(false);

           
        }
    }
}
